# -*- coding: UTF-8 -*-

# 1. for循环迭代字符串
for char in "liangdishui":
    print(char, end=' ')

print()

# 2. for循环迭代list
list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

for i in list:
    print(i, end=' ')

print()
# 3. 创建迭代器
str = "liangdishui"
iter1 = iter(str)
for x in iter1:
    print(x, end=' ')

print()
# 4. 列表生成器

print("\n".join([' '.join('%d×%d=%d\t' % (x, y, x * y) for x in range(1, y + 1)) for y in range(1, 10)]))

print()


# 5. 生成器
def feibo(n):
    a = b = 1
    for i in range(n):
        yield a
        a, b = b, a + b


for x in feibo(100):
    print(x)
